package com.itzdm.message.enums;

import lombok.Getter;

@Getter
public enum MessageType {
    TEXT(1, "文本消息"),
    IMAGE(2, "图片消息"),
    FILE(3, "文件消息"),
    VOICE(4, "语音消息"),
    VIDEO(5, "视频消息");

    private final Integer code;
    private final String description;

    MessageType(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public static MessageType fromCode(Integer code) {
        if (code == null) {
            throw new IllegalArgumentException("消息类型不能为空");
        }
        for (MessageType type : MessageType.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("不支持的消息类型: " + code);
    }
} 